package top.yxqz.studyenum;

import java.util.Random;

/**
 * @author Mr.余
 * @date 2022/11/27
 * @package top.yxqz.studyenum
 */
public class test2 {
    public static void main(String[] args) {
        method1();
//        method2();
    }

    private static void method2() {
        String[] students = {"马超", "张飞", "关羽", "赵云", "黄忠"};
        System.out.println("第一位同学：" + students[0]);
        System.out.println("最后一位同学：" + students[students.length - 1]);
        System.out.println("随机同学：" + students[new Random().nextInt(students.length)]);
    }

    private static void method1() {
        final int number1 = 153;
        final int number2 = 370;
        final int number3 = 371;
        final int number4 = 407;
        for (int i = 100; i < 1000; i++) {
            int a = (i / 100) % 10;
            int b = (i / 10) % 10;
            int c = i % 10;//个位
            if (i == Math.pow(a, 3) + Math.pow(b, 3) + Math.pow(c, 3)) {
                switch (i) {
                    case number1:
                        System.out.println(number1 + "是水仙花数");
                        break;
                    case number2:
                        System.out.println(number2 + "是水仙花数");
                        break;
                    case number3:
                        System.out.println(number3 + "是水仙花数");
                        break;
                    case number4:
                        System.out.println(number4 + "是水仙花数");
                        break;
                }
            }
        }
    }
}
